package com.wecan.web.config;

import com.wecan.web.filter.SecurityPerConfig;
import com.wecan.web.security.StpInterfaceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;

import javax.annotation.PostConstruct;

/**
 * @Author liuzhihao
 * @Date 2022.01.22
 * @Version ${version}
 * @Description ${description}
 */
@Configuration
@Slf4j
public class WebSecurityConfig {

    @PostConstruct
    public void postConstruct() {
        log.info("[APP] |- 加载web层权限底层逻辑");
    }

    @Bean
    @Order(-1)
    @ConditionalOnMissingBean(StpInterfaceImpl.class)
    public StpInterfaceImpl stpInterface() {
        log.info("[APP] |- 加载用户权限bean");
        return new StpInterfaceImpl();
    }

    @Bean
    public SecurityPerConfig securityPerConfig() {
        return new SecurityPerConfig();
    }
}
